package fr.lille.inria.adam.lifl.EcoGardeInventory.Utils;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;
import android.content.Intent;


public final class CommonUtilities {
	
	public static String DEVICE_ID = "myDevice";
	public static final String TYPE_MESSAGE = "message";
	public static final String TYPE_COMMAND = "command";
	public static final String DEFAULT_STATEMENT = "select shake, proximity from ProximityEvent.win:time(5 sec), ShakeEvent.win:time(5 sec)";
	public final static int GET = 1;
	public final static int POST = 2;
    
	
	/**
     * Base URL of the Demo Server (such as http://my_host:8080/gcm-demo)
     */
    public static String mSERVER_URL = "blablabla";

    /**
     * Google API project id registered to use GCM.
     */
    public static final String mSENDER_ID = "1084065691147";
    
    /**
     * Google API KEY to use GCM.
     */
    public static final String API_KEY = "AIzaSyDc7cvxR1eB0Mhq7G9_CJs2GmsVomQGPwE";

    /**
     * Google RegistrationId to use GCM.
     */
    public static String RegistrationId = "";
    
    /**
     * Google RegistrationId to use GCM and deviceIDs.
     */
    public static Map<String,String> DeviceIDsAndRegIDs = new HashMap<String, String>();
    
    /**
     * Tag used on log messages.
     */
    static final String TAG = "EcoGardeInventory Application";

    /**
     * Intent used to display a message in the screen.
     */
    public static final String DISPLAY_MESSAGE_ACTION =
            "fr.lille.inria.adam.lifl.EcoGardeInventory.DISPLAY_MESSAGE";
    
    /**
     * Intent used to execute a command.
     */
    public static final String HANDLE_NOTE_ACTION =
            "fr.lille.inria.adam.lifl.EcoGardeInventory.HANDLE_NOTE";
    
    /**
     * Intent used to handle a shake.
     */
    public static final String HANDLE_SHAKE_ACTION =
            "fr.lille.inria.adam.lifl.EcoGardeInventory.HANDLE_SHAKE";
    
    /**
     * Intent used to handle proximity sensor.
     */
    public static final String HANDLE_PROXIMITY_ACTION =
            "fr.lille.inria.adam.lifl.EcoGardeInventory.HANDLE_PROXIMITY";
    
    /**
     * Intent used to handle a shake.
     */
    public static final String HANDLE_LOCATION_ACTION =
            "fr.lille.inria.adam.lifl.EcoGardeInventory.HANDLE_LOCATION";

    /**
     * Intent's extra that contains the message to be displayed.
     */
    public static final String EXTRA_MESSAGE = "message";
    
    /**
     * Intent's extra that contains the command to be executed.
     */
    public static final String EXTRA_NOTE = "AddNote";
    /**
     * Intent's extra that contains "shake".
     */
    public static final String EXTRA_SHAKE = "shake";
    /**
     * Intent's extra that contains "proximity".
     */
    public static final String EXTRA_PROXIMITY = "proximity";
    /**
     * Intent's extra that contains "Latitude".
     */
    public static final String EXTRA_LATITUDE = "Latitude";
    /**
     * Intent's extra that contains "Latitude".
     */
    public static final String EXTRA_LONGITUDE = "Longitude";
    
    /**
     * Notifies UI to display a message.
     * <p>
     * This method is defined in the common helper because it's used both by
     * the UI and the background service.
     *
     * @param context application's context.
     * @param message message to be displayed.
     */
    public static void displayMessage(Context context, String message) {
        Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
        
        intent.putExtra(EXTRA_MESSAGE, message);
        
        context.sendBroadcast(intent);
    }
    
    /**
     * send an Intent
     */
    public static void handleNote(Context context, String note) {
        Intent intent = new Intent(HANDLE_NOTE_ACTION);
        
        intent.putExtra(EXTRA_NOTE, note);
        
        context.sendBroadcast(intent);
    }
}
